<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,  user-scalable=no">

    <title>GMFCS运动功能评定</title>

    <style>
        #table_guage {
            width: 100%;
        }
    </style>


</head>

<body>
<form>
    <div style="font-size: 16px;height: 26px;margin-bottom: 26px;border-bottom: 1px solid #d0d0d0;">
        <label class="print-font16">评定内容</label>
    </div>
    <div class="hide">
        <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td align="left" width="80px"><label style="font-size: 13px">陪同者</label></td>
                <td align="left"><input type="text" class="form-control" style="width: 200px" id="text_companion"/>
                </td>
            </tr>
        </table>

    </div>

    <!--<div class="view-page hide">-->
    <!--<table border="0" cellspacing="0" cellpadding="0">-->
    <!--<tr>-->
    <!--<td align="left" width="80px"><label style="font-size: 18px">陪同者</label></td>-->
    <!--<td align="left"><label id="span_companion" style="font-weight:normal;font-size: 18px"></label></td>-->
    <!--</tr>-->
    <!--</table>-->
    <!--</div>-->

    <div style="width: 100%;" align="center">
        <form id="form_gauge">
            <div class="table-a">
                <table id="table_guage" border="0" cellspacing="0" cellpadding="0">
                </table>
            </div>
        </form>
        <div class="edit-page hide" style="margin-top: 20px">
            <div class="col-sm-8 col-sm-offset-3">
                <button class="btn btn-white col-sm-3" type="button" onclick="myReset()">重置</button>
                <button class="btn btn-primary col-sm-3 col-sm-offset-1" onclick="submitGaugeResult()"
                        type="button">提交
                </button>
            </div>
        </div>
    </div>
</form>
</body>

<script>

    var textCompanion = $("#text_companion");
    var spanCompanion = $("#span_companion");

    var editPage = $(".edit-page");
    var viewPage = $(".view-page");

    //var gaugeRecordId = $.getUrlParam("gauge_record_id");
    var medicalName = $("#medical_name");

    var gauge_groups = ['GMFCS各级别最高能力描述'];

    var gauge_options = [
        [' ']
    ];

    builderQuestion();

    function builderQuestion() {
        var index = 1;

        for (var i = 0; i < gauge_groups.length; i++) {
            for (var j = 0; j < gauge_options[i].length; j++) {

                if (j == 0) {
                    //添加组标题
                    var groupTr =
//                            "<tr><td  height='30px'></td></tr>" +
                        "<tr><td align='left' ><label style='font-size: 14px;'>" + gauge_groups[i] + "</label></td></tr>";
                    $("#table_guage").append(groupTr);
                }

//                var radio = '<table width="100%"  border="0" cellspacing="0" cellpadding="0">' +
//                        '<tr><td>' +
//                        '<div class="col-sm-3"></div><div class="col-sm-9" style="margin-bottom: 6.5px"><input type="radio" value="1" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>I能够不受限制地行走；在完成更高级的运动技巧上受限</label></div>' +
//                        '<div class="col-sm-3"></div><div class="col-sm-9" style="margin-bottom: 6.5px"><input type="radio" value="2" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>II能够不需要使用辅助器械行走；但是在室外和社区内的行走受限</label></div>' +
//                        '<div class="col-sm-3"></div><div class="col-sm-9" style="margin-bottom: 6.5px"><input type="radio" value="3" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>III使用辅助移动器械行走；在室外和社区的行走受限</label></div>' +
//                        '<div class="col-sm-3"></div><div class="col-sm-9" style="margin-bottom: 6.5px"><input type="radio" value="4" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>IV自身移动受限；孩子需要被转运或者在室外和社区内使用电动移动器械行走</label></div>' +
//                        '<div class="col-sm-3"></div><div class="col-sm-9" ><input type="radio" value="5" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>V即使在使用辅助技术的情况下，自身移动依然严重受限</label></div>' +
//                        '</td></tr>' +
//                        '</table></div>';

                var radio = '<table width="100%"  border="0" cellspacing="0" cellpadding="0">' +
                    '<tr>' +
                    '<td width="20%"></td>' +
                    '<td><div style="margin-bottom: 6.5px"><input type="radio" value="1" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>I能够不受限制地行走；在完成更高级的运动技巧上受限</label></div>' +
                    '</td></tr>' +
                    '<tr>' +
                    '<td width="20%"></td>' +
                    '<td><div  style="margin-bottom: 6.5px"><input type="radio" value="2" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>II能够不需要使用辅助器械行走；但是在室外和社区内的行走受限</label></div>' +
                    '</td></tr>' +
                    '<tr>' +
                    '<td width="20%"></td>' +
                    '<td><div  style="margin-bottom: 6.5px"><input type="radio" value="3" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>III使用辅助移动器械行走；在室外和社区的行走受限</label></div>' +
                    '</td></tr>' +
                    '<tr>' +
                    '<td width="20%"></td>' +
                    '<td><div  style="margin-bottom: 6.5px"><input type="radio" value="4" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>IV自身移动受限；孩子需要被转运或者在室外和社区内使用电动移动器械行走</label></div>' +
                    '</td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td width="20%"></td>' +
                    '<td><div  ><input type="radio" value="5" class="question-radio" onchange="changeSelect()" name="radio_' + i + '_' + j + '"/>V即使在使用辅助技术的情况下，自身移动依然严重受限</label></div>' +
                    '</td>' +
                    '</tr>' +
                    '</table></div>';

                var selectTr = "<tr>" +
                    "<td align='left' style='font-size:13px' id='td_" + i + "_" + j + "'></td>" +
                    "</tr>" +
                    "<tr><td  id='td_select_" + i + "_" + j + "'>" +
                    "</td></tr>" + "<tr><td height='15px'><hr style='height:1px;border:none;border-top:1px dashed #d0d0d0;'/></td></tr>";
                index++;
                $("#table_guage").append(selectTr);
                $("#td_select_" + i + "_" + j).append(radio);
            }
        }

    }

    function changeSelect() {

//        totalScore = 0;
//
//        for (var i = 0; i < gauge_groups.length; i++) {
//            for (var j = 0; j < gauge_options[i].length; j++) {
//                var value = $("input[name='radio_" + i + "_" + j + "']:checked").val();
//                if (typeof(value) == "undefined") {
//                    value = 0;
//                }
//                totalScore += parseInt(value);
//            }
//        }

    }


    function setEditable(edit) {


        if (edit == true || edit == 'true') {
            editPage.removeClass('hide');
            viewPage.addClass('hide');
        } else {
            textCompanion.attr("disabled", true);
            viewPage.removeClass('hide');
            editPage.addClass('hide');
            $(".question-radio").attr('disabled', 'disabled');
        }

    }

    function setGaugeResult(result) {
        for (var i = 0; i < gauge_groups.length; i++) {
            for (var j = 0; j < gauge_options[i].length; j++) {
                var questions = result.questions;
                for (var k = 0; k < questions.length; k++) {
                    if (questions[k].key.trim() == gauge_options[i][j].trim()) {
                        $("input[name='radio_" + i + "_" + j + "'][value=" + questions[k].value + "]").attr("checked", 'checked');
                    }
                }
            }
        }

//        spanCompanion.text(result.companion);
        textCompanion.val(result.companion);
    }


    function getGaugeResult() {
        changeSelect();
        var gauge = {};

//        gauge.total_score = totalScore;

        var questions = [];

//        if (textCompanion.val().trim() == null || textCompanion.val().trim() == '') {
//            utils.msgError("请填写陪同者!");
//            return;
//        }


        var result = $("input[name='radio_0_0']:checked").val();
        if (typeof(result) == "undefined") {
            utils.msgError("还未评估!");
            return;
        }
        var question = {};
        question.key = "";
        question.value = result;
        questions[0] = question;

        gauge.questions = questions;
        gauge.companion = textCompanion.val();

        if (result.companion == null || result.companion == '') {
//            spanCompanion.text("无");
        } else {
//            spanCompanion.text(result.companion);
            textCompanion.val(result.companion);
        }
        debugAlert(gauge);
        return gauge;
    }

    function getCount() {
        $('#form_gauge').get(0).reset();
    }

</script>

</html>
